import axios from '@/libs/axios.js'
import baseUrl from './index'
let jsonHeaders = {'content-type': 'application/json;charset=UTF-8'}

// 训练列表
export const trainList = (params) => {
    return axios({
        url: `${baseUrl}/training/training/page/training`,
        method: 'get',
        headers: jsonHeaders,
        params:params,
    })
}

// 创建训练
export const creatTrain = (params) => {
    return axios({
        url: `${baseUrl}/training/training/training`,
        method: 'post',
        headers: jsonHeaders,
        data:JSON.stringify(params),
    })
}
// 删除训练
export const delTrain = (id) => {
    return axios({
        url: `${baseUrl}/training/training/training/${id}`,
        method: 'delete',
        headers: jsonHeaders,
    })
}
// 修改训练
export const modifyTrain = (params) => {
    return axios({
        url: `${baseUrl}/training/training/training`,
        method: 'put',
        headers: jsonHeaders,
        data:JSON.stringify(params),
    })
}
// 单个训练信息
export const getTrainById = (id) => {
    return axios({
        url: `${baseUrl}/training/training/training/${id}`,
        method: 'get',
        headers: jsonHeaders,
    })
}
// 添加任务
export const creatTask = (params) => {
    return axios({
        url: `${baseUrl}/training/trainingTask/trainingTask`,
        method: 'post',
        headers: jsonHeaders,
        data:JSON.stringify(params),
    })
}
// 任务列表
export const taskList = (params) => {
    return axios({
        url: `${baseUrl}/training/trainingTask/trainingTasks`,
        method: 'get',
        headers: jsonHeaders,
        params:params,
    })
}
// 修改任务
export const modifyTask = (params) => {
    return axios({
        url: `${baseUrl}/training/trainingTask/trainingTask`,
        method: 'put',
        headers: jsonHeaders,
        data:JSON.stringify(params),
    })
}
// 删除任务
export const delTask = (id) => {
    return axios({
        url: `${baseUrl}/training/trainingTask/trainingTask/${id}`,
        method: 'delete',
        headers: jsonHeaders,
    })
}
// 自动生成导调
export const autoAddTask = (id) => {
    return axios({
        url: `${baseUrl}/training/trainingTask/automatic/process/import/${id}`,
        method: 'post',
        headers: jsonHeaders,
    })
}
// 清空导调
export const clearAutoTask = (id) => {
    return axios({
        url: `${baseUrl}/training/training/training/${id}/clean`,
        method: 'post',
        headers: jsonHeaders,
    })
}
// 结束/开始训练
export const startSceneBind = params=>{
    return axios({
        url: `${baseUrl}/process/scenarios/${params.id}/execute?operation=${params.operation}`,
        method: 'post',
        headers: jsonHeaders
    })
}
// 场景信息
export const sceneInfo = (id) => {
    return axios({
        url: `${baseUrl}/process/scenarios/${id}`,
        method: 'get',
        headers: jsonHeaders,
    })
}

// 归档
export const guidang = id=>{
    return axios({
        url: `${baseUrl}/training/training/training/${id}/file`,
        method: 'post',
        headers: jsonHeaders
    })
}
// 学员完成进度列表
export const userTask = (id) => {
    return axios({
        url: `${baseUrl}/training/userTask/score/${id}`,
        method: 'get',
        headers: jsonHeaders,
    })
}
// 查询验证任务列表
export const checkTaskList = (params) => {
    return axios({
        url: `${baseUrl}/training/checkTask/list`,
        method: 'get',
        params:params,
        headers: jsonHeaders,
    })
}
// 创建验证任务
export const addCheckTask = (data) =>{
    return axios({
        url: `${baseUrl}/training/checkTask/insert`,
        method: 'post',
        data:JSON.stringify(data),
        headers: jsonHeaders
    })
}
// 修改验证任务
export const modifyCheckTask = (data) =>{
    return axios({
        url: `${baseUrl}/training/checkTask`,
        method: 'put',
        data:JSON.stringify(data),
        headers: jsonHeaders
    })
}
// 删除验证任务
export const delCheckTask = (id) =>{
    return axios({
        url: `${baseUrl}/training/checkTask/${id}`,
        method: 'delete',
        headers: jsonHeaders
    })
}
// 查询采集任务列表
export const colTaskList = (params) => {
    return axios({
        url: `${baseUrl}/training/collectTask/list`,
        method: 'get',
        params:params,
        headers: jsonHeaders,
    })
}
// 脚本配置列表
export const jbConfList = (params) => {
    return axios({
        url: `${baseUrl}/tasktemplate/item`,
        method: 'get',
        params:params,
        headers: jsonHeaders,
    })
}
// 查看脚本详细配置
export const configInfo = (id) => {
    return axios({
        url: `${baseUrl}/tasktemplate/item/${id}`,
        method: 'get',
        headers: jsonHeaders,
    })
}
// 查看工程中的虚拟机列表
export const getVmList = (data) => {
    return axios({
        url: `${baseUrl}/topo-edit/deployed/projects/${data.id}/vms`,
        method: 'get',
        params:data.data,
        headers: jsonHeaders,
    })
}
// 创建采集任务
export const addCollTask = (data) =>{
    return axios({
        url: `${baseUrl}/training/collectTask/insert`,
        method: 'post',
        data:JSON.stringify(data),
        headers: jsonHeaders
    })
}
// 删除采集任务
export const delColTask = (id) => {
    return axios({
        url: `${baseUrl}/training/collectTask/${id}`,
        method: 'delete',
        headers: jsonHeaders,
    })
}
// 分配的任务列表
export const branchTask = (params) => {
    return axios({
        url: `${baseUrl}/training/trainingTask/structure/list`,
        method: 'get',
        params:params,
        headers: jsonHeaders,
    })
}
// 新建分配任务
export const addBranchlTask = (data) =>{
    return axios({
        url: `${baseUrl}/training/trainingTask/structure/save/obj`,
        method: 'post',
        data:JSON.stringify(data),
        headers: jsonHeaders
    })
}
// 新建分配任务2 数组
export const addBranchlTaskByArr = (data) =>{
    return axios({
        url: `${baseUrl}/training/trainingTask/structure/save/list`,
        method: 'post',
        data:JSON.stringify(data),
        headers: jsonHeaders
    })
}
// 删除分配任务
export const delBranchlTask = (params) =>{
    return axios({
        url: `${baseUrl}/training/trainingTask/structure/delete/team`,
        method: 'delete',
        params:params,
        headers: jsonHeaders
    })
}
// 删除分配任务
export const delBranchl = (params) =>{
    return axios({
        url: `${baseUrl}/training/trainingTask/structure/delete`,
        method: 'delete',
        params:params,
        headers: jsonHeaders
    })
}
// 复制导调任务
export const copyTaskToTeam = (params) =>{
    return axios({
        url: `${baseUrl}/training/trainingTask/structure/copy/team`,
        method: 'post',
        params:params,
        headers: jsonHeaders
    })
}
// 导调节点列表
export const processNodeData = (id) =>{
    return axios({
        url: `${baseUrl}/process/template/exportToJson/${id}`,
        method: 'get',
        headers: jsonHeaders
    })
}
// 获取接入用户组列表
export const getGroupData = (params) =>{
    return axios({
        url: `${baseUrl}/process/accessGroups`,
        method: 'get',
        params:params,
        headers: jsonHeaders
    })
}
// 同步导调任务
export const processData = (data) =>{
    return axios({
        url: `${baseUrl}/training/training/training/${data.trainId}/import?testId=${data.testId}`,
        method: 'post',
        headers: jsonHeaders
    })
}
// 清空训练
export const clearProcess = (id) =>{
    return axios({
        url: `${baseUrl}/training/training/training/${id}/empty`,
        method: 'post',
        headers: jsonHeaders
    })
}
// 修改采集任务
export const modifyColTask = (data) =>{
    return axios({
        url: `${baseUrl}/training/collectTask`,
        method: 'put',
        data:JSON.stringify(data),
        headers: jsonHeaders
    })
}
// 子网络
export const subnetData = (data) =>{
    return axios({
        url: `${baseUrl}/topo-edit/topo/project/${data.id}/tree?types=${data.type}`,
        method: 'get',
        headers: jsonHeaders
    })
}
// 裁判修改最终分数
export const modifyScore = (data) =>{
    return axios({
        url: `${baseUrl}/training/userTask/evaluate/score`,
        method: 'post',
        headers: jsonHeaders,
        data: JSON.stringify(data),
    })
}
//会话查询
export const  getSessions = params => {
    let copy = Object.assign({}, params) // 拷贝一份，不然有影响到页面数据
    if (copy.pageIndex === undefined) {
        copy.pageIndex = copy.page
    }
    if (copy.pageSize === undefined) {
        copy.pageSize = copy.rows
    }
	return axios({
        url:`${baseUrl}/access/sessions`,
        params:copy,
        type:'get',
	})
}
//会话查询
export const  pushNettingData= params => {
	return axios({
    url:`${baseUrl}/notice/internal/pushNettingData/${params.projectId}`,
    method: 'post',
    data: params,
    headers: jsonHeaders
  })
 }
 // 查询修改学员分值的记录
export const  modifyRecord = (params) => {
	return axios({
        url:`${baseUrl}/training/userTask/score/updateRecord`,
        method: 'get',
        params:params,
        headers: jsonHeaders
	})
}
 // 查询报告
 export const  getReport = (id) => {
	return axios({
        url:`${baseUrl}/training/training/training/${id}/report`,
        method: 'get',
        headers: jsonHeaders
	})
}